from cou.api_1_0 import api
from cou.models import Area,Taocan
from flask import jsonify,current_app
from cou import db
from cou.utils.response_code import RET

@api.route('/taocans/<int:taocan_id>')
def get_taocan_detail(taocan_id):
    try:
        taocan=Taocan.query.filter_by(id=taocan_id).first()
    except Exception as e:
        current_app.logger.error(e)
        return jsonify(errno=RET.DBERR,errmsg="数据库错误")
    taocan.check_time+=1
    try:
        db.session.commit()
    except Exception as e:
        db.session.rollback()
        current_app.logger.error(e)
        return jsonify(errno=RET.DBERR,errmsg="数据库错误")
    return jsonify(errno=RET.OK,errmsg="成功",data={'taocan':taocan.to_detail()})
    